package RBNpackage;

public class CombFuncProd extends CombFunc {

	public CombFuncProd() {
		name = "prod";
	}

	@Override
	public double evaluate(double[] args) {
		double prod = 1;
		for (int i=0; i<args.length; i++)
			prod = prod * args[i];
		return prod;
	}

	@Override
	public int evaluatesTo(int[] args) {

		if (args.length == 0 ) return 1;
		if (args.length ==1 && args[0]==1) return 1;
		else{
			boolean existzero = false;
			boolean allones = true;
			for (int i=0;i<args.length;i++){
				if (args[i]!=1) allones = false;
				if (args[i]==0) existzero = true;
			}
			if (allones) return 1;
			if (existzero) return 0;
			return -1;
		}
	}

}
